package com.drakulo.games.ais.ui;

import java.util.ResourceBundle;

import com.drakulo.games.ais.core.Settings;

/**
 * This class handle texts translations using Resource bundles
 * 
 * @author Drakulo
 * 
 */
public final class I18n {
	/** The resource bundle initialized once */
	private static ResourceBundle rb;

	/**
	 * Get the translated value of the key in the current set locale.
	 * 
	 * @param key
	 *            the key to translate
	 * @return the translated value of the key
	 */
	public static String get(String key) {
		if (rb.containsKey(key)) {
			return rb.getString(key);
		}
		return "??" + key + "??";
	}
	
	public static String getFirstToUpper(String key){
		String s = get(key);
		if(s == null || s.startsWith("?")){
			return s;
		}else{
			return FontHelper.firstToUpper(s);
		}
	}

	/**
	 * This method must be called at the game start in order to initialize the
	 * resource bundle
	 */
	public static void initialize() {
		rb = ResourceBundle.getBundle("messages", Settings.CURRENT_LOCALE);
	}
}
